using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

namespace InventorySystem
{
    public class GameItemSpawner : MonoBehaviour
    {
        [SerializeField]
        private GameObject _itemBasePerfab;

        public void SpawnItem(ItemStack itemStack) 
        {
            if (_itemBasePerfab == null) return;
            var item = Instantiate(_itemBasePerfab) as GameObject;
            Vector3 pos = transform.position;
            pos.y += 1 ;
            item.transform.position = pos;
            var gameItemScript = item.GetComponent<GameItem>();
            gameItemScript.SetStack(new ItemStack(itemStack.Item,itemStack.NumberOfItems));
            gameItemScript.Throw(transform.localScale.x);
        }
    }
}